package cn.yunhe.control;

import cn.yunhe.server.TopicServer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/SelectTopicByKeywordServlet")
public class SelectTopicByKeywordServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String keyword = request.getParameter("serch"); //获取查询关键字
        TopicServer topicServer = new TopicServer();

        String result = topicServer.SelectTopicByKeyword(keyword);//输入关键字查询结果
        PrintWriter out = response.getWriter(); //获取out对象
        out.print(result);//输出查询结果
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
